
package com.miexiaoliang.springbootshiro;

import org.apache.shiro.authz.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ShiroExceptionHandler {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * shiro 无权限
     */
    @ExceptionHandler(UnauthorizedException.class)
    @ResponseBody
    public String handleException() {
        logger.info("用户无权限");
        return "用户无权限";
    }

}